import request from './request'

// 文章相关接口
export function getArticleList(params) {
    return request({
        url: '/news/articles',
        method: 'get',
        params
    })
}

export function getArticleById(id) {
    return request({
        url: `/news/articles/${id}`,
        method: 'get'
    })
}

export function createArticle(data) {
    return request({
        url: '/news/articles',
        method: 'post',
        data
    })
}

export function updateArticle(id, data) {
    return request({
        url: `/news/articles/${id}`,
        method: 'put',
        data
    })
}

export function deleteArticle(id) {
    return request({
        url: `/news/articles/${id}`,
        method: 'delete'
    })
}

export function getCategories() {
    return request({
        url: '/news/categories',
        method: 'get'
    })
}

// 评论相关接口
export function getCommentList(params) {
    return request({
        url: '/news/comments',
        method: 'get',
        params
    })
}

export function updateCommentStatus(id, status) {
    return request({
        url: `/news/comments/${id}/status`,
        method: 'patch',
        data: { status }
    })
}

export function deleteComment(id) {
    return request({
        url: `/news/comments/${id}`,
        method: 'delete'
    })
}

export function replyToComment(data) {
    return request({
        url: '/news/comments/reply',
        method: 'post',
        data
    })
}
    